package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.comm.CommContent;
import com.base.po.voip.ShopText;
import com.base.po.voip.Shopinfoes;
import com.base.service.LogsService;
import com.base.service.ShopTextService;
import com.base.service.ShopinfoService;
import com.base.utils.IP;

/**
 * 修改滚动文字信息服务端
 * 
 * @author f
 *
 */
@Controller
@RequestMapping("/admin")
public class update_Roll {

	@Autowired
	private LogsService logsService; // log日志
	@Autowired
	private ShopTextService shopTextService; // 商城滚动文字信息
	@Autowired
	private ShopinfoService shopinfoService; // 发现滚动文字信息

	// 更改商城滚动
	@RequestMapping(value = "/toUpdateMallroll", method = RequestMethod.POST)
	public @ResponseBody int toUpdateMallroll(HttpServletRequest request, ShopText shopText) throws Exception {
		if (request.getSession().getAttribute("adminUserId") == null) return -1; // 未登录
		logsService.insert(CommContent.TYPE_UPDATE, CommContent.LOGS_UPDATE + "改动商城滚动文字信息",
				(String) request.getSession().getAttribute("userNick"), true, IP.getIpAddr(request)); // 记录修改日志
		return shopTextService.updateByPrimaryKeySelective(shopText); // 修改

	}

	// 更改发现滚动
	@RequestMapping(value = "/toUpdateFindroll", method = RequestMethod.POST)
	public @ResponseBody int toUpdateFindroll(HttpServletRequest request, Shopinfoes shopinfoes) throws Exception {
		if (request.getSession().getAttribute("adminUserId") == null) return -1; // 未登录
		logsService.insert(CommContent.TYPE_UPDATE, CommContent.LOGS_UPDATE + "改动发现滚动文字信息",
				(String) request.getSession().getAttribute("userNick"), true, IP.getIpAddr(request)); // 记录修改日志
		return shopinfoService.updateByPrimaryKeySelective(shopinfoes); // 修改
	}
}
